<template>
  <div>
    <el-table
      :data="tableData"
      height="250"
      border
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="时间"
        width="180">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮件"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page=currentPage4
      :page-sizes="[2,4,6,8]"
      :page-size=pageSize
      layout="total, sizes, prev, pager, next, jumper"
      :total=totals
      align="right"
    >
    </el-pagination>
  </div>
</template>

<script>
/*//引入axios
import axios from "axios";*/

export default {
  name: 'user',
  data () {
    return {
      currentPage4: 1,
      pageSize:5,
      totals:0,
      tableData: []
    }
  },
methods:{
    getUsers(){
      let  param={"currentPage":this.currentPage4,"pageSize":this.pageSize}
      this.$http.post("/user/list",param)
      .then(result=>{
        this.tableData = result.data.rows
        this.totals =result.data.totals
      })
      .catch(result=> {
        alert("请求失败！")
      })
  }
  ,
  handleSizeChange(val) {
    this.pageSize=val
    this.currentPage4=1
    this.getUsers()

  },
  handleCurrentChange(val) {
    this.currentPage4=val
    this.getUsers()
  }
},
  mounted() {
    this.getUsers()
  }

}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
